import request from './index'

// 根据分类id获取商品信息
export const getProductsByCategoryId = (categoryId) => {
  return request({
    url: '/product/list',
    method: 'get',
    params: { categoryId }
  })
}

// 根据商品id获取商品详情
export const getProductDetail = (id) => {
  return request({
    url: '/product/detail',
    method: 'get',
    params: { id }
  })
}

// 按名字搜索商品
export const searchByName = (name, categoryId) => {
  return request({
    url: '/product/search',
    method: 'get',
    params: { 
      name: String(name),
      categoryId
    }
  })
}

// 获取收藏列表
export const getFavoriteList = () => {
  return request({
    url: '/favorite/list',
    method: 'get'
  })
}